package com.work04.controller;

import com.work04.pojo.User;
import com.work04.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import java.util.List;

/**
 * @author 绛河
 * @date 2023/5/18
 * @apiNote
 */
@Controller
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    /**
     * 获取user列表并展示到前端userlist.html
     * @param model
     * @return
     */
    @GetMapping("/all")
    public String getAll(Model model){
        List<User> list = userService.list();
        model.addAttribute("list", list);
        return "userList";
    }

}
